package operation;

import book.BookList;
import java.util.Scanner;
import book.Book;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 62536
 * Date: 2023-11-16
 * Time: 10:01
 */
public class FindOperation implements IOPeration {
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书！");
        System.out.println("请写出你要查找的图书的书名：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int currentSize = bookList.getUsedSize();

        for (int i = 0; i < currentSize; i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)) {
                System.out.println("查找成功！");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有你要找的这本书!");


    }
}
